import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-homework',
  templateUrl: './homework.component.html',
  styleUrls: ['./homework.component.css'],
})
export class HomeworkComponent implements OnInit {
  name = 'iphone';
  price = 8999;
  count = 4;
  //事件触发的任务比较复杂，独立写方法
  doMinus() {
    if (this.count == 1) {
      alert('数量最少为1');
      return; //return会终止函数执行
    }
    //this是面向编程语法的关键词，代表当前对象
    this.count--;
  }
  constructor() {}

  ngOnInit(): void {}
}
